const oUser = $('.username');
const oPwd = $('.password');
let oBtn = $('.register');

// 1.登录事件
oBtn.click(function () {
  let username = oUser.val();
  let password = oPwd.val();
  console.log(username);
  // 1.数据请求
  login({
    username,
    password,
  }).then(res => {
    const { status, msg } = res;
    if (status) {
      // 记录是谁登录了
      localStorage.setItem('someone', username);
      const historyUrl = location.search.replace('?HISTORY=', '');
      if (historyUrl) {
        location.href = historyUrl;
      } else {
        // 默认进入商品列表页
        location.href = '../html/1.homepage.html';
      }
    } else {
      alert(msg);
    }
  })

})